<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Enterprise extends Model
{
    const MEAL = [ '1' => '', '1' => '企业基础版', '2' => '通用版  ', '3' => '企业专业版', '4' => '旗舰版', '7' => '企业标准版', '11' => '体验套餐' ];
    public $timestamps = false;
    protected $connection = 'xz';
    protected $table = 'enterprise';
    use HasFactory;

    /**
     *  获取日期.
     *
     * @param string $value
     * @return string
     */
    public function getCreateTimeAttribute(string $value)
    {
        return Date("Y-m-d H:i:s",$value);
    }

    /**
     *  获取开始时间.
     *
     * @param string $value
     * @return string
     */
    public function getSetMealStartAttribute(string $value)
    {
        return Date("Y-m-d H:i:s",$value);
    }

    /**
     *  获取结束时间.
     *
     * @param string $value
     * @return string
     */
    public function getSetMealEndAttribute(string $value)
    {
        return Date("Y-m-d H:i:s",$value);
    }

    /**
     *  获取默认LOGO.
     *
     * @param string $value
     * @return string
     */
    public function getLogAttribute(string $value)
    {
        //如果没有logo
        if(!$value){
            return 'https://xinzhu-1301398555.cos.ap-shanghai.myqcloud.com/wxapp/company-logo.png';
        }
        return $value;
    }

    public function resource()
    {
        return $this->hasOne('App\Models\CompanyResources','eid','id');
    }

}
